package util.translate;

import java.io.IOException;
import java.util.Iterator;
import java.util.List;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;

public class TestJdom {

	/**
	 * jdom测试类
	 */
	public static void main(String[] args) {
		
		String xmlpath = "wordpressSuit.xml";
		SAXBuilder builder = new SAXBuilder(false);
		try {
			Document doc = builder.build(xmlpath);
			Element books = doc.getRootElement();
			List sourcelist = books.getChildren("row");
			for (Iterator iter = sourcelist.iterator(); iter.hasNext();) {
				Element book = (Element) iter.next();
				//System.out.println(book.getChildText("host1"));
				long t1 = System.currentTimeMillis();
				String s1 = book.getChildText("field");
				System.out.println(s1.length());
				Translator translator = new Translator();
				s1 = translator.getTString(s1);
				System.out.println(s1);
				long t2 = System.currentTimeMillis();
				System.out.println(t2-t1);
				
			}
			 /*XMLOutputter outputter=new XMLOutputter();
			 outputter.output(doc,new FileOutputStream(xmlpath));*/
		} catch (JDOMException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}
